<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>联系人管理</title>
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/jquery-easyui-1.8.6/themes/default/easyui.css">
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/jquery-easyui-1.8.6/themes/icon.css">
    <script type="text/javascript" src="${pageContext.request.contextPath}/jquery-easyui-1.8.6/jquery.min.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/jquery-easyui-1.8.6/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/jquery-easyui-1.8.6/locale/easyui-lang-zh_CN.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/jquery-easyui-1.8.6/jquery.edatagrid.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/js/common.js"></script>
</head>
<body style="margin: 15px">

<div id="p" class="easyui-panel" title="客户基本信息" style="width: 700px;height: 100px;padding: 10px">
    <table cellspacing="8px">
        <tr>
            <td>客户编号：</td>
            <td><input class="easyui-textbox" type="text" id="khno" name="khno" readonly="true"/></td>
            <td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
            <td>客户名称</td>
            <td><input class="easyui-textbox" id="name" name="name" readonly="true"/></td>
        </tr>
    </table>
</div>

<br/>
<table id="dg" title="联系人信息管理" style="width:700px;height:400px" toolbar="#toolbar" idField="id" rownumbers="true" fitColumns="true" singleSelect="true">
    <thead>
    <tr>
        <th field="id" width="50">编号</th>
        <th field="linkName" width="100" editor="{type:'textbox',options:{required:true}}">客户姓名</th>
        <th field="sex" width="50" editor="{type:'combobox',
   			options:{
   				valueField:'dataDicValue',
   				textField:'dataDicValue',
   				url:'${pageContext.request.contextPath}/dataDic/dataDicValueComboList.do?dataDicName=性别',
   				required:true,
   				editable:false,
   				panelHeight:'auto'
   		    }}">性别
        </th>
        <th field="zhiWei" width="100" editor="{type:'textbox',options:{required:true}}">职位</th>
        <th field="officePhone" width="100" editor="{type:'textbox',options:{required:true}}">办公电话</th>
        <th field="phone" width="100" editor="{type:'textbox',options:{required:true}}">手机</th>
    </tr>
    </thead>
</table>

<div id="toolbar">
    <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-add" plain="true" onclick="$('#dg').edatagrid('addRow')">添加</a>
    <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-remove" plain="true" onclick="$('#dg').edatagrid('destroyRow')">删除</a>
    <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-save" plain="true" onclick="$('#dg').edatagrid('saveRow')">保存</a>
    <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-undo" plain="true" onclick="$('#dg').edatagrid('cancelRow')">撤销行</a>
</div>
</body>
</html>

<script type="text/javascript">


    $(function () {

        $.post("${pageContext.request.contextPath}/customer/findById.do", {id: '${param.cusId}'}, function (result) {
            $("#khno").textbox("setValue",result.khno);
            $("#name").textbox("setValue",result.name);
        }, "json");

        $("#dg").edatagrid({
            url: '${pageContext.request.contextPath}/linkMan/list.do?cusId=${param.cusId}',
            saveUrl: '${pageContext.request.contextPath}/linkMan/save.do?customer.id=${param.cusId}',
            updateUrl: '${pageContext.request.contextPath}/linkMan/save.do',
            destroyUrl: '${pageContext.request.contextPath}/linkMan/delete.do',
            autoSave: true,
            destroyMsg: {
                norecord: {	// when no record is selected
                    title: '警告',
                    msg: '没有数据被选择。'
                },
                confirm: {	// when select a row
                    title: '确认',
                    msg: '确认要删除吗?'
                }
            },
            onSave: function (index, row) {
                // $('#dg').edatagrid('reload');
            },
            onDestroy: function (index, row) {
                $('#dg').edatagrid('reload');
            },
            onError: function (index, row) {
                // 'isError' 属性设置为 true 的行
                $('#dg').edatagrid('reload');
            },
            onLoadSuccess: function () {
                //加载成功
            }
        });
    });


</script>